﻿using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using SqlSugar;

namespace ApiData.Web.Controllers
{
    public class BaseController : Controller
    {
        public readonly SqlSugarClient context;
        public Common.ResultData Result => new Common.ResultData();

        public Model.user LoginUser
        {
            get
            {
                //var str = HttpContext.Session.GetString("login-user");
                //if (str.IsNullOrWhiteSpace()) return null;
                //return JsonConvert.DeserializeObject<Model.user>(str);

                return new Model.user()
                {
                    id = 1,
                    name = "管理员",
                    account = "admin",
                    password = "L92TxPpv7tQ=",
                    code = "admin"
                };
            }
            set
            {
                var str = JsonConvert.SerializeObject(value);
                HttpContext.Session.SetString("login-user", str);
            }
        }

        public BaseController(SqlSugarClient context)
        {
            this.context = context;
        }
    }
}
